/**
 * 
 */
package org.wit.ecommerce.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * @author brown.hu, Justin
 *
 */
@Entity
@Table(name="jec_transaction")
public class Transaction implements Serializable {

	private static final long serialVersionUID = 6004139231456306209L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	@Column(length=50, nullable=false, unique=true)
	private String pin;
	
	@Column(nullable=false, updatable=false)
	private Timestamp createDate;
	
	@Column(nullable=false)
	private BigDecimal amount;
	
	@Column(nullable=false)
	private BigDecimal price;
	
	public static final String FROM_WEB = "WEB";
	public static final String FROM_MOBILE = "MOBILE";
	@Column(nullable=false, length=10)
	private String transactionSource = FROM_WEB;
	
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="discountid")
	private Discount discount; //discount number
	
	public static final int UNPAID = 0;
	public static final int PAID = 1;
	public static final int SENT = 2;
	public static final int RECEIVED = 3;
	public static final int CANCELLED = 4;
	
	@Column(nullable=false)
	private int status;
	
	@ManyToOne(cascade = {CascadeType.REFRESH}, fetch=FetchType.EAGER)
	@JoinColumn(name="productid")
	private Product product;
	
	@OneToMany(cascade = {CascadeType.ALL}, fetch=FetchType.LAZY, mappedBy="transaction")
	private List<TransactionLog> transactionLogs;
	
	//sender
	@Column(length=30, nullable=false)
	private String senderFirstName;
	
	@Column(length=30)
	private String senderMidName;
	
	@Column(length=30, nullable=false)
	private String senderLastName;
	
	@Column(length=50, nullable=false)
	private String senderCountry;
	
	@Column(length=50, nullable=false)
	private String senderState; 	//province
	
	@Column(length=50)
	private String senderCity;
	
	@Column(length=200)
	private String senderAddress;
	
	@Column(length=20, nullable=false)
	private String senderMobile;
	
	@Column(length=10, nullable=false)
	private String zip;
	
	@Column(length=50, nullable=false)
	private String email;
	
	
	//receiver
	@Column(length=30, nullable=false)
	private String receiverFirstName;
	
	@Column(length=30)
	private String receiverMidName;
	
	@Column(length=30, nullable=false)
	private String reciverLastName;
	
	@Column(length=50, nullable=false)
	private String receiverCountry;
	
	@Column(length=50, nullable=false)
	private String receiverState; 	//province
	
	@Column(length=20, nullable=false)
	private String receiverMobile;
	
	@Column(length=200, nullable=false)
	private String receiverAddress;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getPin() {
		return pin;
	}

	public void setPin(String pin) {
		this.pin = pin;
	}

	public Timestamp getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Timestamp createDate) {
		this.createDate = createDate;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public Discount getDiscount() {
		return discount;
	}

	public void setDiscount(Discount discount) {
		this.discount = discount;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public List<TransactionLog> getTransactionLogs() {
		return transactionLogs;
	}

	public void setTransactionLogs(List<TransactionLog> transactionLogs) {
		this.transactionLogs = transactionLogs;
	}

	public String getSenderFirstName() {
		return senderFirstName;
	}

	public void setSenderFirstName(String senderFirstName) {
		this.senderFirstName = senderFirstName;
	}

	public String getSenderMidName() {
		return senderMidName;
	}

	public void setSenderMidName(String senderMidName) {
		this.senderMidName = senderMidName;
	}

	public String getSenderLastName() {
		return senderLastName;
	}

	public void setSenderLastName(String senderLastName) {
		this.senderLastName = senderLastName;
	}

	public String getSenderCountry() {
		return senderCountry;
	}

	public void setSenderCountry(String senderCountry) {
		this.senderCountry = senderCountry;
	}

	public String getSenderState() {
		return senderState;
	}

	public void setSenderState(String senderState) {
		this.senderState = senderState;
	}

	public String getSenderCity() {
		return senderCity;
	}

	public void setSenderCity(String senderCity) {
		this.senderCity = senderCity;
	}

	public String getSenderAddress() {
		return senderAddress;
	}

	public void setSenderAddress(String senderAddress) {
		this.senderAddress = senderAddress;
	}

	public String getSenderMobile() {
		return senderMobile;
	}

	public void setSenderMobile(String senderMobile) {
		this.senderMobile = senderMobile;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getReceiverFirstName() {
		return receiverFirstName;
	}

	public void setReceiverFirstName(String receiverFirstName) {
		this.receiverFirstName = receiverFirstName;
	}

	public String getReceiverMidName() {
		return receiverMidName;
	}

	public void setReceiverMidName(String receiverMidName) {
		this.receiverMidName = receiverMidName;
	}

	public String getReciverLastName() {
		return reciverLastName;
	}

	public void setReciverLastName(String reciverLastName) {
		this.reciverLastName = reciverLastName;
	}

	public String getReceiverCountry() {
		return receiverCountry;
	}

	public void setReceiverCountry(String receiverCountry) {
		this.receiverCountry = receiverCountry;
	}

	public String getReceiverState() {
		return receiverState;
	}

	public void setReceiverState(String receiverState) {
		this.receiverState = receiverState;
	}

	public String getReceiverMobile() {
		return receiverMobile;
	}

	public void setReceiverMobile(String receiverMobile) {
		this.receiverMobile = receiverMobile;
	}

	public String getReceiverAddress() {
		return receiverAddress;
	}

	public void setReceiverAddress(String receiverAddress) {
		this.receiverAddress = receiverAddress;
	}

	public String getTransactionSource() {
		return transactionSource;
	}

	public void setTransactionSource(String transactionSource) {
		this.transactionSource = transactionSource;
	}	
}
